xen: Fix maximum_gpfn() hypercall to always return max_gpfn not nr_gpfns.
authorKeir Fraser <keir@xensource.com>
Wed, 25 Apr 2007 21:22:31 +0000 (22:22 +0100)
committerKeir Fraser <keir@xensource.com>
Wed, 25 Apr 2007 21:22:31 +0000 (22:22 +0100)
Fix callers to convert this to nr_gpfns (aka p2m_size) if that's what
they actually need.
Signed-off-by: Keir Fraser <keir@xensource.com>
tools/libxc/xc_core_x86.c
tools/libxc/xc_domain_save.c
xen/arch/x86/mm.c
xen/arch/x86/mm/shadow/common.c

index 0f2a19c4515d5b61d1af51b17b495217b3257b82..b3d5d26fbfa15b2ce7a99e521824bebcbc046bc7 100644 (file)
@@ -21,9 +21,9 @@
 #include "xg_private.h"
 #include "xc_core.h"
 
-static int max_gpfn(int xc_handle, domid_t domid)
+static int nr_gpfns(int xc_handle, domid_t domid)
 {
-    return xc_memory_op(xc_handle, XENMEM_maximum_gpfn, &domid);
+    return xc_memory_op(xc_handle, XENMEM_maximum_gpfn, &domid) + 1;
 }
 
 int
@@ -38,7 +38,7 @@ xc_core_arch_memory_map_get(int xc_handle, xc_dominfo_t *info,
                             xc_core_memory_map_t **mapp,
                             unsigned int *nr_entries)
 {
-    unsigned long p2m_size = max_gpfn(xc_handle, info->domid);
+    unsigned long p2m_size = nr_gpfns(xc_handle, info->domid);
     xc_core_memory_map_t *map;
 
     map = malloc(sizeof(*map));
@@ -65,7 +65,7 @@ xc_core_arch_map_p2m(int xc_handle, xc_dominfo_t *info,
     xen_pfn_t *live_p2m_frame_list_list = NULL;
     xen_pfn_t *live_p2m_frame_list = NULL;
     uint32_t dom = info->domid;
-    unsigned long p2m_size = max_gpfn(xc_handle, info->domid);
+    unsigned long p2m_size = nr_gpfns(xc_handle, info->domid);
     int ret = -1;
     int err;
 
index ba7e005819af003d104fb6805cc06bd63e5434df..49fd25b9b66952c24d1bcfe21cb9975376d2a2d3 100644 (file)
@@ -870,7 +870,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
     }
 
     /* Get the size of the P2M table */
-    p2m_size = xc_memory_op(xc_handle, XENMEM_maximum_gpfn, &dom);
+    p2m_size = xc_memory_op(xc_handle, XENMEM_maximum_gpfn, &dom) + 1;
 
     /* Domain is still running at this point */
     if ( live )
index 1c1620d5e52c15ea441540ea1824c562693d0bdc..9ec9c16297bc93cc0b8809449ed0190cd67e09aa 100644 (file)
@@ -249,7 +249,10 @@ int memory_is_conventional_ram(paddr_t p)
 
 unsigned long domain_get_maximum_gpfn(struct domain *d)
 {
-    return is_hvm_domain(d) ? d->arch.p2m.max_mapped_pfn : arch_get_max_pfn(d);
+    if ( is_hvm_domain(d) )
+        return d->arch.p2m.max_mapped_pfn;
+    /* NB. PV guests specify nr_pfns rather than max_pfn so we adjust here. */
+    return arch_get_max_pfn(d) - 1;
 }
 
 void share_xen_page_with_guest(
index 2d57d53c07d2a44495c9fb74e72a455fd41e1e75..1b8d04b76c079103261578c4e32fc81038044efe 100644 (file)
@@ -2668,8 +2668,7 @@ sh_alloc_log_dirty_bitmap(struct domain *d)
 {
     ASSERT(d->arch.paging.shadow.dirty_bitmap == NULL);
     d->arch.paging.shadow.dirty_bitmap_size =
-        (domain_get_maximum_gpfn(d) + (BITS_PER_LONG - 1)) &
-        ~(BITS_PER_LONG - 1);
+        (domain_get_maximum_gpfn(d) + BITS_PER_LONG) & ~(BITS_PER_LONG - 1);
     d->arch.paging.shadow.dirty_bitmap =
         xmalloc_array(unsigned long,
                       d->arch.paging.shadow.dirty_bitmap_size / BITS_PER_LONG);